﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Derbster.Domain
{
    [ContractClass(typeof(TeamRepositoryContracts))]
    public interface ITeamRepository : IQueryable<Team>
    {
        Team Create(string name);
        Team Create(string name, string location);
        Team FindById(int id);
        Team FindByName(string name);
        Team Update(Team team);
        void Delete(Team team);
    }

    [ContractClassFor(typeof(ITeamRepository))]
    public abstract class TeamRepositoryContracts : ITeamRepository
    {
        public IEnumerator<Team> GetEnumerator()
        {
            throw new NotImplementedException();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public Expression Expression
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public Type ElementType
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public IQueryProvider Provider
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public Team Create(string name)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(name));
            Contract.Ensures(Contract.Result<Team>().TeamId > 0);
            return null;
        }

        public Team Create(string name, string location)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(name));
            Contract.Requires(!String.IsNullOrWhiteSpace(location));
            Contract.Ensures(Contract.Result<Team>().TeamId > 0);
            return null;
        }


        public Team FindById(int id)
        {
            Contract.Requires(id > 0);
            return null;
        }

        public Team FindByName(string name)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(name));
            return null;
        }

        public Team Update(Team team)
        {
            Contract.Requires(team != null);
            Contract.Requires(team.TeamId > 0);
            return null;
        }

        public void Delete(Team team)
        {
            Contract.Requires(team != null);
            Contract.Requires(team.TeamId > 0);
        }
    }
}
